package leetcode.code2181;

import leetcode.IDebug;
import leetcode.helper.tree.ListNode;

public class Solution implements IDebug {

	public ListNode mergeNodes(ListNode head) {
		ListNode ans = new ListNode();
		ListNode p = ans;
		while (head.next != null) {
			if (head.val == 0) {
				int sum = 0;
				head = head.next;
				while (head.val != 0) {
					sum += head.val;
					head = head.next;
				}
				ListNode cur = new ListNode(sum);
				p.next = cur;
				p = p.next;
			}
		}
		return ans.next;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
